package com.jiajia.study.nio.chapter01;

import java.nio.ByteBuffer;

/**
 * get() 和 get(int) 的区别
 * get() 会影响 position 的位置
 * get(int) 不会影响 position 的位置
 */
public class TestNio07 {
    public static void main(String[] args) {

        ByteBuffer byteBuffer = ByteBuffer.allocate(10);
        byteBuffer.put(new byte[]{'a','b','c','d'});

        // 切换成读模式
        byteBuffer.flip();

        System.out.println("data is : " + byteBuffer.get(0));
        System.out.println("position is : " + byteBuffer.position());
        System.out.println("data is : " + byteBuffer.get());
        System.out.println("position is : " + byteBuffer.position());
    }
}

